package com.ce.source.analysis.mq;

import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

/**
 * @author ：前世小和尚
 * @Description ：
 * @ClassName ：OrderProducer
 * @date ：2018/3/11 12:21:21
 */
public class OrderProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("gansu-pay");
        producer.setNamesrvAddr("192.168.199.245:9876");
        try {
            producer.start();
            for (int i = 0; i < 10; i++) {
                Message msg = new Message("order", "借款", ("hello world " + i).getBytes("utf-8"));
                SendResult result = producer.send(msg);
                System.out.println(JSON.toJSONString(result));
            }
        } finally {
            producer.shutdown();
        }

    }
}
